
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Chambre
{
    private int capacite;
    private int nbrePatient;
    private Map<String,Patient> patientMap = new HashMap<String,Patient>();
    
    public Chambre()
    {
    }
    
    public void setCapacite(int capacite){
        this.capacite = capacite;    
    }
    public int getCapacite(){
        return this.capacite;
    }
    
    public String infoChambre(){
        String result = "Chambre: Nombre de Patient: " + this.nbrePatient + ", ID Patient: ";
        Iterator<String> it = patientMap.keySet().iterator();
        while(it.hasNext()){
        	result += it.next() + " ";
        }
        return result;
    }
    
    public boolean ajouter(Patient patient)
    {
        if(nbrePatient < capacite)
        {    
        	patient.setChambre(this);
            patientMap.put(patient.getPatientId(), patient);  
            nbrePatient = patientMap.size();
            return true;
        }
        else
        {
            return false;
        }
    }
	
	public void sortir(Patient patient)
	{
		if(patientMap.remove(patient.getPatientId())!=null)
		{
			patient.setChambre(null);
			nbrePatient = patientMap.size();
		}
	}
	
	public Patient getPatient(String patientId)
	{
		return patientMap.get(patientId);
	}
	
	public boolean isDisponible()
	{
		if(nbrePatient < capacite)
			return true;
		else
			return false;
	}
}

